import 'package:flutter/material.dart';
import "./myIcon.dart";

void main() {
  runApp(
    MaterialApp(
      theme: ThemeData(primarySwatch: Colors.red), // FIXME 没生效
      home: Scaffold(
        appBar: AppBar(title: const Text('你好flutter1')),
        body: const ListViewVertical(),
      ),
    ),
  );
}

// 水平列表
class ListViewVertical extends StatelessWidget {
  const ListViewVertical({super.key});
  @override
  Widget build(BuildContext context) {
    return SizedBox(
      height: 120,
      child: ListView(
        // TODO 水平
        scrollDirection: Axis.horizontal,
        children: [
          Container(
              width: 160,
              decoration: const BoxDecoration(color: Colors.red),
              child: Column(
                children: [
                  // 这里是因为图片过大，加个容器限制图片大小
                  SizedBox(
                    height: 100,
                    child: Image.network('https://picsum.photos/400'),
                  ),
                  const Text('这是一个标题')
                ],
              )),
          Container(
            width: 160,
            decoration: const BoxDecoration(color: Colors.yellow),
          ),
          Container(
            width: 160,
            decoration: const BoxDecoration(color: Colors.orange),
          ),
          Container(
            width: 160,
            decoration: const BoxDecoration(color: Colors.teal),
          ),
          Container(
            width: 160,
            decoration: const BoxDecoration(color: Colors.pink),
          ),
          Container(
            width: 160,
            decoration: const BoxDecoration(color: Colors.blue),
          ),
        ],
      ),
    );
  }
}
